// FrameWorkTest.cpp : Defines the entry point for the console application.
//
#define BOOST_TEST_MODULE FrameWork test

#include <boost/test/unit_test.hpp>

#include "..\Framework\CompositorInclude.h"
#include "..\Framework\MetaCpp.h"

#include <iostream>
#include <string>
class IWork
{
public:
	virtual std::string Do() = 0 ;

};

class WorkerA : public IWork
{
public:
	std::string Do()
	{
		
		return "A" ;
	}
};

class WorkerB : public IWork
{
public:
	std::string Do()
	{
		
		return "B" ;
	}
	~WorkerB()
	{
		using std::cout;
		using std::endl;

		cout << "BDestroy" << endl;
	}
};

class WorkerTeam : public ABCCompositor_1Ret0Arg<std::string,IWork,&IWork::Do,_traits<std::string,CRetModAgg<std::string>>>
{

};

BOOST_AUTO_TEST_CASE(Compositors)
{
	WorkerTeam a2;

	///WorkerTeam a2;
	a2.addItem(new WorkerA);
	a2.addItem(new WorkerB);
	a2.addItem(new WorkerA);
	a2.addItem(new WorkerB);
	
	BOOST_CHECK_EQUAL( std::strcmp( a2.IterateThrough().c_str(), "ABAB" ), 0 );

	//FlowForward2<ABCCompositor_1Ret0Arg<std::string,IWork,&IWork::Do,_traits<std::string,CRetModAgg<std::string>>>>(&a2);
	

	a2.clear();

}

template <typename U>
class Handler
{
public:
	typedef	U RET;
};

template <typename U>
class	RetVal
{
public:
	typedef typename IF<
							ISVOID<U>::RET,
							Handler<int>,
							Handler<double>
						>::RET::RET RET;
	RET	m_Int;
};

//template <class PEA,void (PEA::*funcPtr)(),class TRAITS = _traits<void>>
//class ABCCompositor : public virtual BaseCompositor<PEA>
//{
//public:
//
//	template <class PEA> friend  class CompositorFlow;
//	typedef CompositorIterator<ABCCompositor>	iterator;
//	typedef typename void (PEA::*functor)();
//	void IterateThrough();
//
//};
//
////Compositor ABC Class 1 RetVal 0 Args
//template <class RET , class PEA , RET (PEA::*funcPtr)(),class TRAITS = _traits<RET>>
//class ABCCompositor_1Ret0Arg : public virtual BaseCompositor<PEA>
//{
//public:
//	typedef	typename	RET	_RET;
//	typedef CompositorIterator<ABCCompositor_1Ret0Arg>	iterator;
//	typedef typename RET (PEA::*functor)();
//	RET IterateThrough();
//};


template <typename returnType,class PEA,returnType (PEA::*funcPtr)()>
class CompositorFactory
{
public:
	//typedef typename returnType (PEA::*funcPtr)();

	typedef typename IF<ISVOID<returnType>::RET,
		ABCCompositor<PEA,funcPtr>,
		ABCCompositor_1Ret0Arg<returnType,PEA,funcPtr>
	>::RET	COMPOSITOR;
};
BOOST_AUTO_TEST_CASE(MetaCpp)
{
	
	BOOST_CHECK_EQUAL(ISVOID<void>::RET ,true);
	BOOST_CHECK_EQUAL(ISVOID<int>::RET ,false);

	RetVal<void>::RET	a;
	BOOST_CHECK_EQUAL(sizeof(a) == sizeof(int),true);
	BOOST_CHECK_EQUAL(sizeof(a) == sizeof(double),false);

	CompositorFactory<void,IWork,CREATE_FUNCTION_POINTER(IWork,Do)>::COMPOSITOR	a2;
}
//int main(int argc, char* argv[])
//{
//
//
//	
//	
//	return 0;
//}

